package com.zhuangfei.timetable.listener;

import com.zhuangfei.timetable.model.Schedule;
import com.zhuangfei.timetable.utils.TextUtils;
import ohos.agp.components.StackLayout;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;

/**
 * Item构建监听器的默认实现.
 */

public class OnItemBuildAdapter implements ISchedule.OnItemBuildListener {
    @Override
    public String getItemText(Schedule schedule, boolean isThisWeek) {
        if (schedule == null || TextUtils.isEmpty(schedule.getName())){
            return "未命名";
        }
        if (schedule.getRoom() == null) {
            if (!isThisWeek){
                return "[非本周]" + schedule.getName();
            }
            return schedule.getName();
        }

        String room = schedule.getName() + "@" + schedule.getRoom();
        if (!isThisWeek) {
            room = "[非本周]" + room;
        }
        return room;
    }

    @Override
    public void onItemUpdate(StackLayout layout, Text textView, Text countTextView, Schedule schedule, ShapeElement gd) {
    }
}
